<template>
  <div class="seller-order-manage">
    <div class="page-header">
      <h2>订单管理</h2>
    </div>

    <!-- 搜索和筛选区域 -->
    <div class="search-filter-section">
      <div class="search-row">
        <!-- 关键词搜索 -->
        <div class="search-item">
          <label>关键词搜索：</label>
          <input 
            v-model="searchParams.keyword" 
            type="text" 
            placeholder="请输入订单号、商品名称等关键词"
            class="search-input"
            @keyup.enter="searchOrders"
          />
        </div>

        <!-- 订单状态筛选 -->
        <div class="search-item">
          <label>订单状态：</label>
          <select v-model="searchParams.status" class="search-select">
            <option value="">全部状态</option>
            <option value="0">待支付</option>
            <option value="1">已支付</option>
            <option value="2">部分发货</option>
            <option value="3">全部发货</option>
            <option value="4">已完成</option>
            <option value="5">已取消</option>
          </select>
        </div>

        <!-- 发货状态筛选 -->
        <div class="search-item">
          <label>发货状态：</label>
          <select v-model="searchParams.itemStatus" class="search-select">
            <option value="">全部状态</option>
            <option value="0">未发货</option>
            <option value="1">已发货</option>
            <option value="2">已完成</option>
            <option value="3">已取消</option>
          </select>
        </div>

        <!-- 搜索按钮 -->
        <div class="search-item">
          <button @click="searchOrders" class="search-btn">搜索</button>
          <button @click="resetSearch" class="reset-btn">重置</button>
          <button class="export-btn" @click="exportOrdersToExcel" :disabled="loading">导出为 Excel</button>
        </div>
      </div>
    </div>

    <!-- 订单列表 -->
    <div class="order-list-section">
      <div v-if="loading" class="loading">加载中...</div>
      
      <div v-else-if="orderList.length === 0" class="no-data">
        暂无订单数据
      </div>

      <div v-else class="order-table">
        <table>
          <thead>
            <tr>
              <th>订单号</th>
              <th>下单时间</th>
              <th>买家信息</th>
              <th>商品信息</th>
              <th>订单金额</th>
              <th>订单状态</th>
              <th>发货状态</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="order in orderList" :key="order.orderId" class="order-row">
              <td class="order-id">{{ order.orderId }}</td>
              <td>{{ formatDate(order.createTime) }}</td>
              <td>
                <div class="customer-info">
                  <div>{{ order.customerName }}</div>
                  <div class="customer-address">{{ order.address }}</div>
                </div>
              </td>
              <td>
                <div class="product-info">
                  <div v-if="order.orderItemVO" class="product-item">
                    <img :src="order.orderItemVO.productImage?.trim()" :alt="order.orderItemVO.productName" class="product-image" />
                    <div class="product-details">
                      <div class="product-name">{{ order.orderItemVO.productName }}</div>
                      <div class="product-spec">{{ order.orderItemVO.skuName }}</div>
                      <div class="product-quantity">数量: {{ order.orderItemVO.quantity }}</div>
                    </div>
                  </div>
                </div>
              </td>
              <td class="order-amount">¥{{ order.orderItemVO?.totalPrice || 0 }}</td>
              <td>
                <span :class="getOrderStatusClass(order.status)">
                  {{ getOrderStatusText(order.status) }}
                </span>
              </td>
              <td>
                <span :class="getItemStatusClass(order.orderItemVO?.status)">
                  {{ getItemStatusText(order.orderItemVO?.status) }}
                </span>
              </td>
              <td class="actions">
                <button @click="viewOrderDetail(order.orderId)" class="action-btn view-btn">查看详情</button>
                <button 
                  v-if="order.status === 1 && order.orderItemVO?.status === 0" 
                  @click="shipOrderAction(order)" 
                  class="action-btn ship-btn">
                  发货
                </button>
              </td>
            </tr>
          </tbody>
        </table>
      </div>

      <!-- 分页组件 -->
      <div v-if="orderList.length > 0" class="pagination">
        <div class="page-size-selector">
          <label>每页显示：</label>
          <select v-model="pageSize" @change="changePageSize" class="page-size-select">
            <option value="10">10条</option>
            <option value="20">20条</option>
            <option value="50">50条</option>
            <option value="100">100条</option>
          </select>
        </div>
        
        <div class="pagination-info">
          共 {{ totalCount }} 条记录，第 {{ currentPage }} / {{ totalPages }} 页
        </div>
        <div class="pagination-controls">
          <button 
            @click="changePage(currentPage - 1)" 
            :disabled="currentPage <= 1"
            class="page-btn"
          >
            上一页
          </button>
          
          <span v-for="page in getPageNumbers()" :key="page" class="page-number">
            <button 
              v-if="page !== '...'"
              @click="changePage(page)" 
              :class="{ active: page === currentPage }"
              class="page-btn"
            >
              {{ page }}
            </button>
            <span v-else class="page-ellipsis">...</span>
          </span>
          
          <button 
            @click="changePage(currentPage + 1)" 
            :disabled="currentPage >= totalPages"
            class="page-btn"
          >
            下一页
          </button>
        </div>
      </div>
    </div>

    <!-- 订单详情模态框 -->
    <div v-if="showOrderDetail" class="modal-overlay" @click="closeOrderDetail">
      <div class="modal-content" @click.stop>
        <div class="modal-header">
          <h3>订单详情</h3>
          <button class="close-btn" @click="closeOrderDetail">&times;</button>
        </div>
        <div class="modal-body" v-if="orderDetail">
          <div class="order-info">
            <h4>订单信息</h4>
            <div class="info-row">
              <span class="label">订单号：</span>
              <span>{{ orderDetail.orderId }}</span>
            </div>
            <div class="info-row">
              <span class="label">订单总价：</span>
              <span class="price">¥{{ orderDetail.totalPrice }}</span>
            </div>
            <div class="info-row">
              <span class="label">创建时间：</span>
              <span>{{ formatTime(orderDetail.createTime) }}</span>
            </div>
            <div class="info-row" v-if="orderDetail.payTime">
              <span class="label">支付时间：</span>
              <span>{{ formatTime(orderDetail.payTime) }}</span>
            </div>
            <div class="info-row" v-if="orderDetail.deliveryTime">
              <span class="label">发货时间：</span>
              <span>{{ formatTime(orderDetail.deliveryTime) }}</span>
            </div>
            <div class="info-row" v-if="orderDetail.finishTime">
              <span class="label">完成时间：</span>
              <span>{{ formatTime(orderDetail.finishTime) }}</span>
            </div>
          </div>

          <div class="seller-orders" v-for="seller in orderDetail.orderCustomerBySellers" :key="seller.sellerId">
            <h4>{{ seller.sellerName }}</h4>
            <div class="seller-total">
              <span class="label">商家订单总价：</span>
              <span class="price">¥{{ seller.totalPrice }}</span>
            </div>
            
            <div class="order-items">
              <div class="item-card" v-for="item in seller.orderItemVOList" :key="item.id">
                <div class="item-image">
                  <img :src="item.productImage" :alt="item.productName" />
                </div>
                <div class="item-details">
                  <div class="item-name">{{ item.productName }}</div>
                  <div class="item-sku">规格：{{ item.skuName }}</div>
                  <div class="item-address">收货地址：{{ item.address }}</div>
                  <div class="item-price-info">
                    <span class="unit-price">单价：¥{{ item.price }}</span>
                    <span class="quantity">数量：{{ item.quantity }}</span>
                    <span class="total-price">小计：¥{{ item.totalPrice }}</span>
                  </div>
                  <div class="item-status">
                    <span class="status-badge" :class="getItemStatusClass(item.status)">
                      {{ getItemStatusText(item.status) }}
                    </span>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { ref, reactive, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getSellerOrders, getOrderDetail, shipOrder } from '@/api/order'

export default {
  name: 'SellerOrderManage',
  setup() {
    // 响应式数据
    const loading = ref(false)
    const orderList = ref([])
    const currentPage = ref(1)
    const pageSize = ref(10)
    const totalCount = ref(0)
    const totalPages = ref(0)
    const showOrderDetail = ref(false)
    const orderDetail = ref(null)

    // 改变每页显示数量
    const changePageSize = () => {
      currentPage.value = 1
      getOrderList()
    }

    // 搜索参数
    const searchParams = reactive({
      keyword: '',
      status: '',
      itemStatus: ''
    })

    // 获取商家ID (从localStorage或其他地方获取)
    const sellerId = ref(localStorage.getItem('sellerId') || 1)

    // 获取订单列表
    const getOrderList = async () => {
      loading.value = true
      try {
        const params = {
          pageNum: currentPage.value,
          pageSize: pageSize.value,
          sellerId: sellerId.value,
          ...searchParams
        }

        // 过滤空值参数
        Object.keys(params).forEach(key => {
          if (params[key] === '' || params[key] === null || params[key] === undefined) {
            delete params[key]
          }
        })

        const response = await getSellerOrders(params)
        
        if (response && response.list) {
          orderList.value = response.list
          totalCount.value = response.total
          totalPages.value = response.pages
          currentPage.value = response.pageNum
        }
      } catch (error) {
        console.error('获取订单列表失败:', error)
        ElMessage.error('获取订单列表失败，请稍后重试')
      } finally {
        loading.value = false
      }
    }

    // 搜索订单
    const searchOrders = () => {
      currentPage.value = 1
      getOrderList()
    }

    // 重置搜索
    const resetSearch = () => {
      searchParams.keyword = ''
      searchParams.status = ''
      searchParams.itemStatus = ''
      currentPage.value = 1
      getOrderList()
    }

    // 切换页码
    const changePage = (page) => {
      if (page >= 1 && page <= totalPages.value) {
        currentPage.value = page
        getOrderList()
      }
    }

    // 获取页码数组
    const getPageNumbers = () => {
      const pages = []
      const total = totalPages.value
      const current = currentPage.value

      if (total <= 7) {
        for (let i = 1; i <= total; i++) {
          pages.push(i)
        }
      } else {
        if (current <= 4) {
          for (let i = 1; i <= 5; i++) {
            pages.push(i)
          }
          pages.push('...')
          pages.push(total)
        } else if (current >= total - 3) {
          pages.push(1)
          pages.push('...')
          for (let i = total - 4; i <= total; i++) {
            pages.push(i)
          }
        } else {
          pages.push(1)
          pages.push('...')
          for (let i = current - 1; i <= current + 1; i++) {
            pages.push(i)
          }
          pages.push('...')
          pages.push(total)
        }
      }
      return pages
    }

    // 导出订单到 Excel
    const exportOrdersToExcel = async () => {
      if (orderList.value.length === 0) {
        ElMessage.warning('暂无订单数据可导出');
        return;
      }

      try {
        const XLSX = await import('xlsx');
        // 格式化订单数据
        const exportData = orderList.value.map(order => ({
          '订单号': order.orderId,
          '下单时间': formatDate(order.createTime),
          '买家姓名': order.customerName,
          '收货地址': order.address,
          '商品名称': order.orderItemVO?.productName || '',
          '规格': order.orderItemVO?.skuName || '',
          '数量': order.orderItemVO?.quantity || 0,
          '订单金额': `¥${order.orderItemVO?.totalPrice || 0}`,
          '订单状态': getOrderStatusText(order.status),
          '发货状态': getItemStatusText(order.orderItemVO?.status)
        }));

        // 创建工作表和工作簿
        const ws = XLSX.utils.json_to_sheet(exportData);
        const wb = XLSX.utils.book_new();
        XLSX.utils.book_append_sheet(wb, ws, '订单列表');

        // 生成并下载文件
        XLSX.writeFile(wb, `订单列表_${new Date().toLocaleDateString()}.xlsx`);
        ElMessage.success('导出成功');
      } catch (error) {
        console.error('导出失败:', error);
        ElMessage.error('导出失败，请检查依赖是否安装');
      }
    };

    // 格式化日期
    const formatDate = (dateString) => {
      if (!dateString) return ''
      const date = new Date(dateString)
      return date.toLocaleString('zh-CN')
    }

    // 获取订单状态文本
    const getOrderStatusText = (status) => {
      const statusMap = {
        0: '待支付',
        1: '已支付',
        2: '部分发货',
        3: '全部发货',
        4: '已完成',
        5: '已取消'
      }
      return statusMap[status] || '未知状态'
    }

    // 获取订单状态样式类
    const getOrderStatusClass = (status) => {
      const classMap = {
        0: 'status-pending',
        1: 'status-paid',
        2: 'status-partial-shipped',
        3: 'status-shipped',
        4: 'status-completed',
        5: 'status-cancelled'
      }
      return `order-status ${classMap[status] || ''}`
    }

    // 获取发货状态文本
    const getItemStatusText = (status) => {
      const statusMap = {
        0: '未发货',
        1: '已发货',
        2: '已完成',
        3: '已取消'
      }
      return statusMap[status] || '未知状态'
    }

    // 获取发货状态样式类
    const getItemStatusClass = (status) => {
      const classMap = {
        0: 'item-status-pending',
        1: 'item-status-shipped',
        2: 'item-status-completed',
        3: 'item-status-cancelled'
      }
      return `item-status ${classMap[status] || ''}`
    }

    // 查看订单详情
    const viewOrderDetail = async (orderId) => {
      try {
        const response = await getOrderDetail(orderId)
        if (response) {
          orderDetail.value = response
          showOrderDetail.value = true
        }
      } catch (error) {
        console.error('获取订单详情失败:', error)
        ElMessage.error('获取订单详情失败，请稍后重试')
      }
    }

    // 关闭订单详情
    const closeOrderDetail = () => {
      showOrderDetail.value = false
      orderDetail.value = null
    }

    // 格式化时间
    const formatTime = (timeString) => {
      if (!timeString) return '-'
      return new Date(timeString).toLocaleString('zh-CN')
    }

    // 发货操作
    const shipOrderAction = async (order) => {
      try {
        await ElMessageBox.confirm(
          `确认发货订单 ${order.orderId} 吗？`,
          '提示',
          {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }
        )

        const payload = {
          orderId: order.orderId,
          ItemId: order.orderItemVO.id,
          // 可以添加物流单号和物流公司
          // trackingNumber: '',
          // shippingCompany: ''
        }
        
        await shipOrder(payload)
        ElMessage.success('发货成功！')
        // 刷新订单列表
        getOrderList()
      } catch (error) {
        if (error !== 'cancel') { // 用户取消操作时，error为'cancel'
          console.error('发货失败:', error)
          ElMessage.error('发货失败，请稍后重试')
        }
      }
    }

    // 组件挂载时获取数据
    onMounted(() => {
      getOrderList()
    })

    return {
      loading,
      orderList,
      currentPage,
      pageSize,
      totalCount,
      totalPages,
      searchParams,
      getOrderList,
      searchOrders,
      resetSearch,
      changePage,
      changePageSize,
      getPageNumbers,
      formatDate,
      getOrderStatusText,
      getOrderStatusClass,
      getItemStatusText,
      getItemStatusClass,
      viewOrderDetail,
      shipOrderAction,
      showOrderDetail,
      orderDetail,
      closeOrderDetail,
      formatTime,
      exportOrdersToExcel
    }
  }
}
</script>

<style scoped>
.seller-order-manage {
  padding: 20px;
  background-color: #f5f5f5;
  min-height: 100vh;
  max-height: 100vh;
  overflow-y :auto;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h2 {
  color: #333;
  font-size: 24px;
  margin: 0;
}

/* 搜索筛选区域 */
.search-filter-section {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-item label {
  font-weight: 500;
  color: #333;
  white-space: nowrap;
}

.search-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 250px;
  font-size: 14px;
}

.search-input:focus {
  outline: none;
  border-color: #007bff;
}

.search-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 150px;
  font-size: 14px;
  background: white;
}

.search-select:focus {
  outline: none;
  border-color: #007bff;
}

.search-btn, .reset-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.search-btn {
  background-color: #007bff;
  color: white;
}

.search-btn:hover {
  background-color: #0056b3;
}

.export-btn {
  background-color: #28a745;
  color: white;
}

.export-btn:hover {
  background-color: #218838;
}

.reset-btn {
  background-color: #6c757d;
  color: white;
  margin-left: 10px;
}

.reset-btn:hover {
  background-color: #545b62;
}

/* 订单列表区域 */
.order-list-section {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  overflow: hidden;
}

.loading, .no-data {
  text-align: center;
  padding: 40px;
  color: #666;
  font-size: 16px;
}

.order-table {
  overflow-x: auto;
}

.order-table table {
  width: 100%;
  border-collapse: collapse;
}

.order-table th,
.order-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.order-table th {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #333;
}

.order-row:hover {
  background-color: #f8f9fa;
}

.order-id {
  font-family: monospace;
  color: #007bff;
  font-weight: 500;
}

.customer-info {
  min-width: 120px;
}

.customer-address {
  color: #666;
  font-size: 12px;
  margin-top: 4px;
  max-width: 150px;
  word-wrap: break-word;
}

.product-info {
  max-width: 300px;
}

.product-item {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f0f0f0;
}

.product-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.product-image {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
}

.product-details {
  flex: 1;
}

.product-name {
  font-weight: 500;
  margin-bottom: 4px;
}

.product-spec, .product-quantity {
  font-size: 12px;
  color: #666;
  margin-bottom: 2px;
}

.order-amount {
  font-weight: 600;
  color: #e74c3c;
  font-size: 16px;
}

/* 状态样式 */
.order-status, .item-status {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  display: inline-block;
}

.status-pending { background-color: #fff3cd; color: #856404; }
.status-paid { background-color: #d4edda; color: #155724; }
.status-partial-shipped { background-color: #cce7ff; color: #004085; }
.status-shipped { background-color: #d1ecf1; color: #0c5460; }
.status-completed { background-color: #d4edda; color: #155724; }
.status-cancelled { background-color: #f8d7da; color: #721c24; }

.item-status-pending { background-color: #fff3cd; color: #856404; }
.item-status-shipped { background-color: #d1ecf1; color: #0c5460; }
.item-status-completed { background-color: #d4edda; color: #155724; }
.item-status-cancelled { background-color: #f8d7da; color: #721c24; }

/* 操作按钮 */
.actions {
  min-width: 120px;
}

.action-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  margin-right: 8px;
  transition: background-color 0.3s;
}

.view-btn {
  background-color: #007bff;
  color: white;
}

.view-btn:hover {
  background-color: #0056b3;
}

.ship-btn {
  background-color: #28a745;
  color: white;
}

.ship-btn:hover {
  background-color: #1e7e34;
}

/* 订单详情模态框样式 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  margin: 0;
  color: #333;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  color: #333;
}

.modal-body {
  padding: 20px;
}

.order-info {
  margin-bottom: 30px;
  padding: 20px;
  background-color: #f8f9fa;
  border-radius: 6px;
}

.order-info h4 {
  margin: 0 0 15px 0;
  color: #333;
  font-size: 16px;
}

.info-row {
  display: flex;
  margin-bottom: 10px;
}

.info-row .label {
  font-weight: 500;
  color: #666;
  min-width: 100px;
}

.info-row .price {
  color: #e74c3c;
  font-weight: 600;
}

.seller-orders {
  margin-bottom: 30px;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 20px;
}

.seller-orders h4 {
  margin: 0 0 15px 0;
  color: #333;
  font-size: 16px;
}

.seller-total {
  margin-bottom: 20px;
  padding: 10px;
  background-color: #f8f9fa;
  border-radius: 4px;
}

.seller-total .label {
  font-weight: 500;
  color: #666;
}

.seller-total .price {
  color: #e74c3c;
  font-weight: 600;
}

.order-items {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.item-card {
  display: flex;
  padding: 15px;
  border: 1px solid #eee;
  border-radius: 6px;
  background-color: #fff;
}

.item-image {
  width: 80px;
  height: 80px;
  margin-right: 15px;
  flex-shrink: 0;
}

.item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.item-details {
  flex: 1;
}

.item-name {
  font-size: 16px;
  font-weight: 500;
  color: #333;
  margin-bottom: 8px;
}

.item-sku {
  font-size: 14px;
  color: #666;
  margin-bottom: 5px;
}

.item-address {
  font-size: 14px;
  color: #666;
  margin-bottom: 10px;
}

.item-price-info {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
  font-size: 14px;
}

.unit-price, .quantity {
  color: #666;
}

.total-price {
  color: #e74c3c;
  font-weight: 600;
}

.item-status {
  display: flex;
  align-items: center;
}

.status-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

/* 分页样式 */
.pagination {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #eee;
}

.page-size-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-size-selector label {
  font-size: 14px;
  color: #666;
  white-space: nowrap;
}

.page-size-select {
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  background: white;
  cursor: pointer;
}

.page-size-select:focus {
  outline: none;
  border-color: #007bff;
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-info {
  color: #666;
  font-size: 14px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-btn {
  padding: 6px 12px;
  border: 1px solid #ddd;
  background: white;
  color: #333;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

.page-btn:hover:not(:disabled) {
  background-color: #007bff;
  color: white;
  border-color: #007bff;
}

.page-btn:disabled {
  background-color: #f8f9fa;
  color: #6c757d;
  cursor: not-allowed;
}

.page-btn.active {
  background-color: #007bff;
  color: white;
  border-color: #007bff;
}

.page-number {
  display: inline-block;
}

.page-ellipsis {
  padding: 6px 4px;
  color: #666;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .search-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-item {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-input, .search-select {
    width: 100%;
  }
  
  .order-table {
    font-size: 12px;
  }
  
  .pagination {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  
  .page-size-selector {
    margin-bottom: 10px;
  }
}
</style>